local fire_attack = fk.CreateSkill{
  name = "hl_ex__huoji__fire_attack_skill",
}

Fk:loadTranslationTable{
  ["hl_ex__huoji__fire_attack_skill"] = "火攻",
}

fire_attack:addEffect("cardskill", {
  prompt = "#fire_attack_skill",
  can_use = Util.CanUse,
  target_num = 1,
  mod_target_filter = function(self, _, to_select, _, _, _)
    return not to_select:isKongcheng()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local from = effect.from
    local to = effect.to
    if to:isKongcheng() then return end

    local params = { ---@type AskToCardsParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = fire_attack.name,
      cancelable = false,
      pattern = ".|.|.|hand",
      prompt = "#fire_attack-show:" .. from.id
    }
    local showCard = room:askToCards(to, params)[1]
    to:showCards(showCard)

    showCard = Fk:getCardById(showCard)

    local ex_ids = from.room:getNCards(4)
    params = { ---@type AskToDiscardParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = fire_attack.name,
      cancelable = true,
      pattern = ".|.|" .. showCard:getSuitString(),
      prompt = "#hl_ex__huoji-discard:" .. to.id .. "::" .. showCard:getSuitString(),
      expand_pile = ex_ids,
    }

    local cards = room:askToCards(from, params)
    if #cards > 0  then
      local who = not table.contains(ex_ids, cards[1]) and from or nil
      from.room:throwCard(cards, fire_attack.name, who, from)
    end

    if #cards > 0 and not to.dead then
      room:damage{
        from = from,
        to = to,
        card = effect.card,
        damage = 1,
        damageType = fk.FireDamage,
        skillName = "fire_attack_skill",
      }
    end
  end,
})

return fire_attack
